package org.dtrd.modules.doctor.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.swagger.models.auth.In;
import org.dtrd.modules.doctor.entity.bean.DoctorSigninSuggestDetail;
import org.dtrd.modules.doctor.entity.bean.DoctorSigninSuggestListInfo;
import org.dtrd.modules.doctor.entity.bean.SigninSuggestDetail;
import org.dtrd.modules.doctor.entity.bean.SigninSuggestListInfo;
import org.dtrd.modules.doctor.entity.po.DtrdEntRdDoctorSigninSuggest;
import org.dtrd.modules.doctor.entity.po.DtrdEntRdSigninSuggest;
import org.dtrd.modules.doctor.mapper.DtrdEntRdPatientSigninSuggestMapper;
import org.dtrd.modules.doctor.service.IDtrdEntRdPatientSigninSuggestService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;


/**
 * <p>
 * 打卡建议 服务实现类
 * </p>
 *
 * @author 5146
 * @since 2022-04-08
 */
@DS("multi-datasource1")
@Service
public class DtrdEntRdPatientSigninSuggestServiceImpl extends ServiceImpl<DtrdEntRdPatientSigninSuggestMapper, DtrdEntRdSigninSuggest> implements IDtrdEntRdPatientSigninSuggestService {

    private DtrdEntRdPatientSigninSuggestMapper dtrdEntRdSigninSuggestMapper;

    @Override
    public List<String> getSigninSuggest(Integer signinType) {
        return baseMapper.listSigninSuggest(signinType);
    }

    @Override
    public boolean updateSigninSuggest(Integer dataId, String signinContent) {
        DtrdEntRdSigninSuggest request = getById(dataId);
        if (request != null && signinContent != null) {
            request.setSuggestContent(signinContent);
            return updateById(request);
        } else {
            return false;
        }
    }

    @Override
    public boolean saveSigninSuggest(DtrdEntRdSigninSuggest dtrdEntRdSigninSuggest) {
        //取出相应参数
        String suggestContent = dtrdEntRdSigninSuggest.getSuggestContent();
        Integer signinType = dtrdEntRdSigninSuggest.getSigninType();
        //建立我们所需要的链表
        DtrdEntRdDoctorSigninSuggest dtrdEntRdDoctorSigninSuggest = new DtrdEntRdDoctorSigninSuggest();
        dtrdEntRdDoctorSigninSuggest.setSigninType(signinType);
        dtrdEntRdDoctorSigninSuggest.setSuggestContent(suggestContent);
        //执行插入操作————插入到医生建议表中
        return true;  //save(doctorSigninSuggestDetail);
    }

    private LambdaQueryWrapper<DtrdEntRdSigninSuggest> baseQueryWrapper() {
        return Wrappers.lambdaQuery(DtrdEntRdSigninSuggest.class)
                        .eq(DtrdEntRdSigninSuggest::getIsDel, 0);
    }

    private LambdaUpdateWrapper<DtrdEntRdSigninSuggest> baseUpdateWrapper() {
        return Wrappers.lambdaUpdate(DtrdEntRdSigninSuggest.class)
                        .eq(DtrdEntRdSigninSuggest::getIsDel, 0);
    }
}
